<template>
  <div>
    <div class="btn"><el-button type="primary" @click="add">添加</el-button></div>
    <v-table @edit="edit"></v-table>
    <v-window :info="info" ref="addInfo"></v-window>
  </div>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
import vTable from "./component/table.vue";
import vWindow from "./component/window.vue";
export default {
  components: {
    vTable,
    vWindow,
  },
  data() {
    return {
      info: {
        isshow: false,
        isAdd: true, //true添加，false编辑
      },
    };
  },
  computed: {
    ...mapGetters({}),
  },
  methods: {
    ...mapActions({}),
    
    //点击添加按钮
    add(){
      this.info.isshow=true;
      this.info.isAdd=true;
    },
    //表格中点击编辑按钮，在父组件中执行
    edit(id){
      this.info.isshow=true;
      this.info.isAdd=false;
      this.$refs.addInfo.getOne(id);
    },
  },
  mounted() {
    
  },
};
</script>

<style lang="less" scoped>
@import "../../less/index.less";
.btn {
  margin-bottom: @margin;
}
</style>